package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.pojo.User;
import com.itheima.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author likepei
 * @Date 2020/1/17 12:17
 * @Version v1.0
 * @Description 用户控制器
 */
@RestController
@RequestMapping("/user")
public class UserController {

    //依赖注入Service
    @Reference(loadbalance="roundrobin")
    public UserService userService;

     /**
     * 根据id查询用户
     * @param id 用户id
     * @return 用户对象
     */
    //@ResponseBody
    @RequestMapping("/findById")
    public User findById(Integer id){
        User user = userService.findById(id);
        return user;
    }
}
